package cn.edu.jju.stepcounter2.main.model;


import android.util.Log;

import org.xutils.DbManager;
import org.xutils.ex.DbException;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

import cn.edu.jju.stepcounter2.SCApp;
import cn.edu.jju.stepcounter2.bean.DayData;

/**
* Created by roor on 2016/12/08
*/

public class MainModelImpl implements MainModel{

    @Override
    public void getData( OnDataGetListener onDataGetListener) {
        DbManager.DaoConfig daoConfig = SCApp.daoConfig;
        DbManager dbManager = x.getDb(daoConfig);
        List<DayData> all =new ArrayList<>();

        try {
            all = dbManager.selector(DayData.class).findAll();
            Log.i("@@@", "getData" + all.size());
        } catch (DbException e) {
            e.printStackTrace();
            onDataGetListener.onDataGetFailed(e.getMessage());
        }
        onDataGetListener.onDataGetSuccess(all);

    }
}